-
Notifications
You must be signed in to change notification settings - Fork 474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support for linux scheduler and timer #64
Open
neo5167
wants to merge
38
commits into
lewissbaker:master
Choose a base branch
from
neo5167:linux_scheduler_timer_support
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
4d1845b
Turn off warnings about std::result_of_t usage on latest msvc compiler.
lewissbaker c549df8
support for linux scheduler and timer
neo5167 af44da4
restructuring the code to reduce ifdefs
neo5167 26e6c72
conforming to the white space and indentation rules.
neo5167 3ecdf4a
Update .travis.yml to refer to clang-7
lewissbaker 377deb8
Try clang-7.0 instead of clang-7 package name
lewissbaker 48e1ef5
Fix clang-7 apt package names again
lewissbaker 7d0f2df
Try setting CLANG_VERSION=7 instead of 7.0 in Travis config
lewissbaker 862e99d
[README] Add C++ highlighting for 'schedule_on' (#67)
modocache 936e6ee
Remove possible warnings with redefinitions
attila0x2A a19b13b
Merge pull request #71 from think-cell/redef_warnings
lewissbaker 4963e33
Update appveyor.yml to ignore x86 optimised failures
lewissbaker 53d4a06
Merge pull request #76 from lewissbaker/appveyor-tweaks
lewissbaker a4d2c7b
Correct file_write_operation's friend class
attila0x2A 98d98e2
Merge pull request #77 from think-cell/correct_file_write
lewissbaker b0e5f76
Fix typo in async_generator state description
attila0x2A 14ad4bd
Fix io_service_fixture_with_threads: create given threads count (#75)
grishavanika bce2a72
Replace <iosfwd> with <ostream> in doctest.h to try and fix linker er…
lewissbaker 5aa1cd1
[AppVeyor] Reenable VS 2017 Preview build variants
lewissbaker 2492c07
Link against vcruntime[d].lib instead of msvcurt[d].lib
lewissbaker 115aa39
fixed the minor comments from lewis.
neo5167 e5dc2fc
changes for white space based on clang-format.el
neo5167 d02cab7
copyright block
neo5167 b23f640
support for linux scheduler and timer
neo5167 723c049
restructuring the code to reduce ifdefs
neo5167 b8db839
conforming to the white space and indentation rules.
neo5167 cc86c9b
fixed the minor comments from lewis.
neo5167 343fe0a
changes for white space based on clang-format.el
neo5167 2565005
copyright block
neo5167 b006b04
rebasing with upstream master and fixing some windows bugs.
7fec714
fixing merge conflicts.
87910b8
removing repeated files from cake.
8007d4f
indentation fixes.
ab4b9b7
indentation fixes.
d38a213
more indentation changes. Moving from cc mode to llvm style.
1696936
reverting some changes since the functions are no longer needed.
751232b
windows tests passing.
f870053
All linux tests passing.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1854,7 +1854,7 @@ task<> example() | |
``` | ||
|
||
API Summary: | ||
``` | ||
```c++ | ||
// <cppcoro/schedule_on.hpp> | ||
namespace cppcoro | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
/////////////////////////////////////////////////////////////////////////////// | ||
// Copyright (c) Microsoft | ||
// Licenced under MIT license. See LICENSE.txt for details. | ||
/////////////////////////////////////////////////////////////////////////////// | ||
#pragma once | ||
|
||
#include <mqueue.h> | ||
#include <sys/epoll.h> | ||
#include <sys/timerfd.h> | ||
#include <sys/eventfd.h> | ||
#include <fcntl.h> | ||
#include <uuid/uuid.h> | ||
#include <sys/resource.h> | ||
#include <sys/stat.h> | ||
#include <linux/limits.h> | ||
#include <sys/epoll.h> | ||
#include <unistd.h> | ||
#include <utility> | ||
|
||
namespace cppcoro | ||
{ | ||
namespace detail | ||
{ | ||
namespace linux | ||
{ | ||
using fd_t = int; | ||
|
||
enum message_type | ||
{ | ||
CALLBACK_TYPE, | ||
RESUME_TYPE | ||
}; | ||
|
||
class safe_fd | ||
{ | ||
public: | ||
|
||
safe_fd() | ||
: m_fd(-1) | ||
{} | ||
|
||
explicit safe_fd(fd_t fd) | ||
: m_fd(fd) | ||
{} | ||
|
||
safe_fd(const safe_fd& other) = delete; | ||
|
||
safe_fd(safe_fd&& other) noexcept | ||
: m_fd(other.m_fd) | ||
{ | ||
other.m_fd = -1; | ||
} | ||
|
||
~safe_fd() | ||
{ | ||
close(); | ||
} | ||
|
||
safe_fd& operator=(safe_fd fd) noexcept | ||
{ | ||
swap(fd); | ||
return *this; | ||
} | ||
|
||
constexpr fd_t fd() const { return m_fd; } | ||
|
||
/// Calls close() and sets the fd to -1. | ||
void close() noexcept; | ||
|
||
void swap(safe_fd& other) noexcept | ||
{ | ||
std::swap(m_fd, other.m_fd); | ||
} | ||
|
||
bool operator==(const safe_fd& other) const | ||
{ | ||
return m_fd == other.m_fd; | ||
} | ||
|
||
bool operator!=(const safe_fd& other) const | ||
{ | ||
return m_fd != other.m_fd; | ||
} | ||
|
||
bool operator==(fd_t fd) const | ||
{ | ||
return m_fd == fd; | ||
} | ||
|
||
bool operator!=(fd_t fd) const | ||
{ | ||
return m_fd != fd; | ||
} | ||
|
||
private: | ||
|
||
fd_t m_fd; | ||
|
||
}; | ||
|
||
struct message | ||
{ | ||
enum message_type m_type; | ||
void* m_ptr; | ||
}; | ||
|
||
struct io_state : linux::message | ||
{ | ||
using callback_type = void(io_state* state); | ||
callback_type* m_callback; | ||
}; | ||
|
||
class message_queue | ||
{ | ||
private: | ||
mqd_t m_mqdt; | ||
char m_qname[NAME_MAX]; | ||
safe_fd m_epollfd; | ||
struct epoll_event m_ev; | ||
message_queue(); | ||
public: | ||
message_queue(size_t queue_length); | ||
~message_queue(); | ||
bool enqueue_message(void* message, message_type type); | ||
bool dequeue_message(void*& message, message_type& type, bool wait); | ||
}; | ||
|
||
safe_fd create_event_fd(); | ||
safe_fd create_timer_fd(); | ||
safe_fd create_epoll_fd(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change this to use #ifdef include guards to be consistent with other headers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add a copyright/license header as per the existing source files?
Please attribute copyright to the appropriate entity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will have to circle back on this. Have to speak with our team here to get the appropriate rights entity name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.