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
import requests | |
root_url = 'http://localhost:47334' | |
# Spcify the training data and the value you want predicted | |
train_data_url = 'https://raw.githubusercontent.com/mindsdb/mindsdb-examples/master/benchmarks/heart_disease/processed_data/train.csv' | |
train_data = { | |
'to_predict': 'target', | |
'from_data': train_data_url | |
} |
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
Nov 04 16:31:00 george-laptop kernel: INFO: task kcompactd0:77 blocked for more than 120 seconds. | |
Nov 04 16:31:00 george-laptop kernel: Not tainted 4.18.14-arch1-1-ARCH #1 | |
Nov 04 16:31:00 george-laptop kernel: "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. | |
Nov 04 16:31:00 george-laptop kernel: kcompactd0 D 0 77 2 0x80000000 | |
Nov 04 16:31:00 george-laptop kernel: Call Trace: | |
Nov 04 16:31:00 george-laptop kernel: ? __schedule+0x29b/0x8b0 | |
Nov 04 16:31:00 george-laptop kernel: schedule+0x32/0x90 | |
Nov 04 16:31:00 george-laptop kernel: schedule_timeout+0x311/0x4a0 | |
Nov 04 16:31:00 george-laptop kernel: ? enqueue_task_fair+0xc3/0x730 | |
Nov 04 16:31:00 george-laptop kernel: ? native_sched_clock+0x5d/0x90 |
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
//Return a weak pointer, this resource is shared but whoever gets it shouldn't own it | |
weak_ptr get_widget(); | |
void use_widget() { | |
auto widget_weak_ptr = get_widget(); | |
//Check if the underylingwidget has already been destroyed. | |
if(auto widget_ptr = widget_weak_ptr.lock()) { |
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
//Return a shared pointer, meaning this resource is shared | |
//Someone else might be using the underlying object | |
shared_ptr get_widget(); | |
int use_widget() { | |
auto widget_ptr = get_widget(); | |
//Thus we shall take the thread-safe approach and lock the widget before using it | |
widget_ptr->lock_widget_mutex(); | |
if(widget_ptr->get_status() == 42) | |
widget_ptr->trigger_event(); |
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
//Return a unique pointer,meaning we have sole ownership of the widget | |
unique_ptr get_widget(); | |
void use_widget() { | |
//Thus we don't need to Lock it to call its methods | |
//We can move the unique_ptr to function after we are done with it | |
//Or just forget about it and it shall free the underlying ressource | |
auto widget_ptr = get_widget(); | |
if(widget_ptr->get_status() == 42) | |
widget_ptr->trigger_event(); |
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
//The header of Widget (the important bits for us) | |
class Widget { | |
public: | |
void lock_widget_mutex(); | |
void unlock_widget_mutex(); | |
int get_status() const; | |
void trigger_event(); | |
} |
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
std::weak_ptr non_owner_ptr; | |
if (auto shared_owner_ptr = non_owner_ptr.lock()) { | |
shared_owner_ptr->do_stuff() | |
} |
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
extern crate tokio; | |
extern crate futures; | |
use futures::future; | |
use tokio::{net::TcpStream, prelude::Future}; | |
use std::net::SocketAddr; | |
fn send(addr: SocketAddr, message: String) { | |
let task = TcpStream::connect(&addr) | |
.and_then(|stream| tokio::io::write_all(stream, message)) |
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
import asyncio | |
async def send(addr, port, message): | |
con = asyncio.open_connection(addr, port) | |
reader, writer = await con | |
writer.write(message) | |
buffer_size = 254 | |
data = await reader.read(buffer_size) |
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
use std::thread; | |
fn work(magic_number: i32) { /* implementation */ } | |
fn main() { | |
t1 = thread::spawn(|| work(46)); | |
t2 = thread::spawn(|| work(3)); | |
t1.join() | |
t2.join() |
NewerOlder